home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 27.zip / BS1 part 27 / ImageMaster_d3.adf / piarc.lzh.parta / HLInfo.rexx < prev    next >
OS/2 REXX Batch file  |  1993-03-23  |  4KB  |  137 lines

  1. /*
  2.  * HLInfo.rexx
  3.  *
  4.  *  Written by: Pete Patterson
  5.  * Last Update: May 28, 1992
  6.  *         For: Black Belt Systems image processing series IM, IM F/c, and IP.
  7.  * ---------------------------------------------------------------------------
  8.  *    Revision: 1.0
  9.  */
  10. call pragma('stack',20000);
  11.  
  12. /*
  13.  * open rexxsupport.library -- needed for some functions
  14.  */
  15. if ~show('L',"rexxsupport.library") then do
  16.   if addlib('rexxsupport.library',0,-30,0) then do
  17.       /* everything's ok */
  18.     end;
  19.   else do
  20.     say 'We Have A Library Problem, Unable To Load "rexxsupport.library"';
  21.     say 'Cannot operate Subscribe.rexx without this library - sorry!';
  22.     exit 10;
  23.     end;
  24.   end;
  25.  
  26. /*
  27.  * This will automatically direct the script to the proper
  28.  * software, if it is running.
  29.  */
  30. prtnme = 'IP_Port'; /* assume Image Professional */
  31. if show('P','IP_Port') = 0 then do
  32.   if show('P','IM_Port') = 0 then do
  33.     say "Can't find image processor's ARexx port!!!"; /* not running? */
  34.     say "This script requires IP, IM or IM F/c to run!";
  35.     exit(20);
  36.     end;
  37.   else do
  38.     prtnme = 'IM_Port'; /* That's the thing about assumptions... */
  39.     end;                 /* We make em, user's break em.          */
  40.   end;
  41.  
  42.   /*
  43.    * This code attempts to read a file called "picmdpath" from REXX:
  44.    * If it can't find it, the script will assume that the commands
  45.    * associated with this PI Module are in "c:". If the file exists,
  46.    * the script will look in the path that is specified in the file.
  47.    * If you create this file, you MUST put a complete, correct path
  48.    * in it; if the commands are in a sub-directory, you have to put
  49.    * the trailing slash on the path (like, device:dir/).
  50.    * 
  51.    */
  52.   cmdpath = 'c:';
  53.   if open(fhandle,'rexx:picmdpath','read') then  /* open the file */
  54.     do
  55.       cmdpath = readln(fhandle);
  56.       call close(fhandle);  /* close the file    */
  57.     end
  58.  
  59. options;
  60. address;
  61.  
  62.   prevpath = 'ram:'; /* put user in ram to start with... */
  63.  
  64.   if show('C',hl_path) = 1 then do
  65.     prevpath = getclip(hl_path);
  66.     end;
  67.  
  68.   address(prtnme);
  69.   options results;
  70.   'wbtofront';
  71.  
  72.   address command cmdpath||'HLInfo';
  73.   if rc ~= 0 then do
  74.     address(prtnme);
  75.     'message "Hotlinks error"';
  76.     exit 0; /* this is not a proper hotlink file */
  77.     end;
  78.  
  79.   'imtofront'; /* show user the IM screen */
  80.   address(prtnme);
  81.   'imtofront';
  82.   address;
  83.  
  84.   exit 0;
  85.  
  86. /*
  87.  * gimmepath
  88.  *
  89.  * This takes the provided argument and sucks the path out of it, then
  90.  * returns that path to the caller, sans file name.
  91.  */
  92. gimmepath:
  93.   arg fullnamegx;
  94.     tempgx = reverse(fullnamegx);
  95.     lengx = length(fullnamegx);   /* get length of string */
  96.     slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
  97.     colondex = index(tempgx,':');  /* first occurance of ':' from right */
  98.     seploc = 0; /* assumes current dir, no path supplied */
  99.     if slashdex ~= 0 then do /* we assume we are in a DIR */
  100.       seploc = (lengx - slashdex)+1;
  101.       end;
  102.     else do
  103.       if colondex ~= 0 then do /* we assume we are on a device */
  104.         seploc = (lengx - colondex)+1;
  105.         end;
  106.       end;
  107.   gxname = substr(fullnamegx,seploc+1); /* if you ever need it */
  108.   gxpath = left(fullnamegx,seploc);
  109.   return(gxpath);
  110.  
  111. /*
  112.  * Since this script can't be expected to know where the CD of the user
  113.  * is when this cmd is invoked, we have to check the path the user
  114.  * provides - if it's not specified right from a root, then we have
  115.  * to make it a complete specification from the root.
  116.  */
  117. expandfilename:
  118.   parse arg jfile;
  119.   if index(jfile,':') = 0 then do
  120.     curdir = pragma(D);
  121.     if right(curdir,1) ~= ':' then do
  122.       if right(curdir,1) ~= '/' then do
  123.         if curdir ~= '' then do
  124.           curdir = curdir || '/';
  125.           end;
  126.         end;
  127.       end;
  128.     jfile = curdir||jfile;
  129.     end;
  130.   return(jfile);
  131.  
  132. rvalue:
  133.   wordnum = c2d(readch(fhandle,1)) * 256;
  134.   wordnum = wordnum + c2d(readch(fhandle,1));
  135.   return wordnum;
  136.  
  137.